﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Erp.Migrations
{
    /// <inheritdoc />
    public partial class add_modify_InboundRec : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "DiscountTotal",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "MaterialWhseCodg",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "MaterialWhseName",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "OrderNo",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "SupplierCodg",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "BatchNumber",
                schema: "Erp",
                table: "InboundRecDetls");

            migrationBuilder.DropColumn(
                name: "MaterialInfoCodg",
                schema: "Erp",
                table: "InboundRecDetls");

            migrationBuilder.RenameColumn(
                name: "PurchaseDateTime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "PurchaseDatetime");

            migrationBuilder.RenameColumn(
                name: "BillingDateTime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "BillingDatetime");

            migrationBuilder.RenameColumn(
                name: "WarehouseId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "MaterialWhseId");

            migrationBuilder.RenameColumn(
                name: "TotalRetailTotal",
                schema: "Erp",
                table: "InboundRecs",
                newName: "PurchaseAmt");

            migrationBuilder.RenameColumn(
                name: "SupplierName",
                schema: "Erp",
                table: "InboundRecs",
                newName: "InboundOrderNo");

            migrationBuilder.RenameColumn(
                name: "PurchaseTotal",
                schema: "Erp",
                table: "InboundRecs",
                newName: "DiscountAmt");

            migrationBuilder.RenameColumn(
                name: "ExtensionData",
                schema: "Erp",
                table: "InboundRecs",
                newName: "Exp");

            migrationBuilder.RenameColumn(
                name: "ArrivalDate",
                schema: "Erp",
                table: "InboundRecs",
                newName: "ArrivalDatetime");

            migrationBuilder.RenameColumn(
                name: "ManufactureDateTime",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "ManufactureDatetime");

            migrationBuilder.RenameColumn(
                name: "ValidityDateTime",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "ValiDatetime");

            migrationBuilder.RenameColumn(
                name: "RetailPrice",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "TotalRtalAmt");

            migrationBuilder.RenameColumn(
                name: "RetailAmount",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "RtalAmt");

            migrationBuilder.RenameColumn(
                name: "PurchaseAmount",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "PurchaseAmt");

            migrationBuilder.RenameColumn(
                name: "MaterialInfoName",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "BatchNo");

            migrationBuilder.RenameColumn(
                name: "DiscountAmount",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "DiscountAmt");

            migrationBuilder.AddColumn<Guid>(
                name: "MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<bool>(
                name: "TrdnFlag",
                schema: "Erp",
                table: "InboundRecDetls",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.CreateIndex(
                name: "IX_InboundRecs_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MaterialSupplierId");

            migrationBuilder.CreateIndex(
                name: "IX_InboundRecs_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MaterialWhseId");

            migrationBuilder.CreateIndex(
                name: "IX_InboundRecDetls_MaterialInfoId",
                schema: "Erp",
                table: "InboundRecDetls",
                column: "MaterialInfoId");

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecDetls_MaterialInfos_MaterialInfoId",
                schema: "Erp",
                table: "InboundRecDetls",
                column: "MaterialInfoId",
                principalSchema: "Erp",
                principalTable: "MaterialInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecs_MaterialSuppliers_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MaterialSupplierId",
                principalSchema: "Erp",
                principalTable: "MaterialSuppliers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecs_MaterialWhses_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MaterialWhseId",
                principalSchema: "Erp",
                principalTable: "MaterialWhses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecDetls_MaterialInfos_MaterialInfoId",
                schema: "Erp",
                table: "InboundRecDetls");

            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecs_MaterialSuppliers_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecs_MaterialWhses_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropIndex(
                name: "IX_InboundRecs_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropIndex(
                name: "IX_InboundRecs_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropIndex(
                name: "IX_InboundRecDetls_MaterialInfoId",
                schema: "Erp",
                table: "InboundRecDetls");

            migrationBuilder.DropColumn(
                name: "MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "TrdnFlag",
                schema: "Erp",
                table: "InboundRecDetls");

            migrationBuilder.RenameColumn(
                name: "PurchaseDatetime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "PurchaseDateTime");

            migrationBuilder.RenameColumn(
                name: "BillingDatetime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "BillingDateTime");

            migrationBuilder.RenameColumn(
                name: "PurchaseAmt",
                schema: "Erp",
                table: "InboundRecs",
                newName: "TotalRetailTotal");

            migrationBuilder.RenameColumn(
                name: "MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "WarehouseId");

            migrationBuilder.RenameColumn(
                name: "InboundOrderNo",
                schema: "Erp",
                table: "InboundRecs",
                newName: "SupplierName");

            migrationBuilder.RenameColumn(
                name: "Exp",
                schema: "Erp",
                table: "InboundRecs",
                newName: "ExtensionData");

            migrationBuilder.RenameColumn(
                name: "DiscountAmt",
                schema: "Erp",
                table: "InboundRecs",
                newName: "PurchaseTotal");

            migrationBuilder.RenameColumn(
                name: "ArrivalDatetime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "ArrivalDate");

            migrationBuilder.RenameColumn(
                name: "ManufactureDatetime",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "ManufactureDateTime");

            migrationBuilder.RenameColumn(
                name: "ValiDatetime",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "ValidityDateTime");

            migrationBuilder.RenameColumn(
                name: "TotalRtalAmt",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "RetailPrice");

            migrationBuilder.RenameColumn(
                name: "RtalAmt",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "RetailAmount");

            migrationBuilder.RenameColumn(
                name: "PurchaseAmt",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "PurchaseAmount");

            migrationBuilder.RenameColumn(
                name: "DiscountAmt",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "DiscountAmount");

            migrationBuilder.RenameColumn(
                name: "BatchNo",
                schema: "Erp",
                table: "InboundRecDetls",
                newName: "MaterialInfoName");

            migrationBuilder.AddColumn<decimal>(
                name: "DiscountTotal",
                schema: "Erp",
                table: "InboundRecs",
                type: "numeric(18,4)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "MaterialWhseCodg",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "MaterialWhseName",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "OrderNo",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "SupplierCodg",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "BatchNumber",
                schema: "Erp",
                table: "InboundRecDetls",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "MaterialInfoCodg",
                schema: "Erp",
                table: "InboundRecDetls",
                type: "text",
                nullable: false,
                defaultValue: "");
        }
    }
}
